<template>
    <div>
          <el-table
            :data="tableData"
            style="width: 100%">

            <el-table-column
            label="商品详情"
            width="120">
            <template slot-scope="scope">
                <div slot="reference" class="name-wrapper">
                    <router-link :to="'/detail?category='+scope.row.category+'&id='+scope.row.id" style="color:black">
                        <img :src="require('@/assets/'+scope.row.category+'/'+scope.row.id+'/1.jpg')" style="width: 100px; height: 100px"><br>
                    </router-link>
                </div>
            </template>
            </el-table-column>

            <el-table-column
            label="商品分类"
            width="100">
            <template slot-scope="scope">
                <div slot="reference" class="name-wrapper">
                    <el-tag size="medium">{{ scope.row.category }}</el-tag>
                </div>
            </template>
            </el-table-column>

            <el-table-column
            label="商品标题"
            width="400">
            <template slot-scope="scope">
                <div slot="reference" class="name-wrapper">
                    <el-tag size="medium">{{ scope.row.title }}</el-tag>
                </div>
            </template>
            </el-table-column>

            <el-table-column
            label="店铺归属"
            width="100">
            <template slot-scope="scope">
                <div slot="reference" class="name-wrapper">
                    <el-tag size="medium">{{ scope.row.shop }}</el-tag>
                </div>
            </template>
            </el-table-column>

            <el-table-column
            label="商品价格"
            width="100">
            <template slot-scope="scope">
                <div slot="reference" class="name-wrapper">
                    <el-tag size="medium">{{ scope.row.price }}</el-tag>
                </div>
            </template>
            </el-table-column>

            <el-table-column
            label="购买人数"
            width="100">
            <template slot-scope="scope">
                <div slot="reference" class="name-wrapper">
                    <el-tag size="medium">{{ scope.row.buyer }}</el-tag>
                </div>
            </template>
            </el-table-column>

            <el-table-column
            label="库存数量"
            width="100">
            <template slot-scope="scope">
                <div slot="reference" class="name-wrapper">
                    <el-tag size="medium">{{ scope.row.stock }}</el-tag>
                </div>
            </template>
            </el-table-column>

            <el-table-column label="操作">
            <template slot-scope="scope">
                <el-button
                size="mini"
                type="success"
                style="margin-left:10px"
                @click="handleAccept(scope.row)">通过</el-button>

                <el-button
                size="mini"
                type="danger"
                style="margin-left:10px"
                @click="handleDelete(scope.row)">不通过</el-button>
            </template>
            </el-table-column>

        </el-table>
    </div>
</template>

<script>
export default {
    name: "checkshop",
    data() {
      return {
        tableData: []
      }
    },
    methods: {
        handleDelete(row) {
            this.$axios.post("/api/updateStatus",this.$querystring.stringify({
            id:row.id,
            category:row.category,
            status: 'no'
            })).then(reponse=>{
            console.log(reponse);
            if(reponse.data == true){
                /*
                成功跳转
                */
               alert("不通过成功")
            }else{
                alert("系统错误")
            }
        })
      },
      handleAccept(row){
            this.$axios.post("/api/updateStatus",this.$querystring.stringify({
            id:row.id,
            category:row.category,
            status: 'ok'
            })).then(reponse=>{
            console.log(reponse);
            if(reponse.data == true){
                /*
                成功跳转
                */
               alert("通过成功")
            }else{
                alert("系统错误")
            }
        })
      }
    },
    mounted(){
        if(this.$cookies.get("checkshop_second") != 'ok'){
            alert("无权限");
            this.$router.push("/adminindex")
        }else{
            this.$axios.get("/api/getAllCheck").then(res=>{
                this.tableData = res.data
            });
        }
    }
}
</script>

<style scoped>

</style>